/*
 * @Author: your name
 * @Date: 2021-08-30 11:28:50
 * @LastEditTime: 2021-12-28 10:30:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\api\dataStatistics\server.js
 */
import Api from './api.js'
import request from '@/utils/request'
import axios from 'axios'

export const DataStatistics = {
    // 反馈关闭率
    FeedBackClosingRate(_data) {
        return request.post(Api.FeedBackClosingRate, _data)
    },
    // 反馈部门处理时长
    FeedBackDepDuration(_data) {
        return request.post(Api.FeedBackDepDuration, _data)
    },
    // 反馈来源处理时长
    FeedBackSourceDuration(_data) {
        return request.post(Api.FeedBackSourceDuration, _data)
    },
    // 阶段关闭时长
    FeedBackStageDuration(_data) {
        return request.post(Api.FeedBackStageDuration, _data)
    },
    // 反馈关闭原因
    FeedBackReason(_data) {
        return request.post(Api.FeedBackReason, _data)
    },
    // 反馈解决方案
    FeedBackSolution(_data) {
        return request.post(Api.FeedBackSolution, _data)
    },
    // 任务关闭原因
    TaskCloseReason(_data) {
        return request.post(Api.TaskCloseReason, _data)
    },
    // 任务关闭率
    TaskClosingRate(_data) {
        return request.post(Api.TaskClosingRate, _data)
    },
    // 任务部门处理时长
    TaskDepDuration(_data) {
        return request.post(Api.TaskDepDuration, _data)
    },
    // C1 未关闭阶段图表
    C1FeedBackStage(_data) {
        return request.post(Api.C1FeedBackStage, _data)
    },
    // C1 未关闭状态图表
    C1FeedBackStatus(_data) {
        return request.post(Api.C1FeedBackStatus, _data)
    },
    // C1 未关闭C2 状态
    C2tate(_data) {
        return request.post(Api.C2tate, _data)
    },
    // C1 未关闭阶段图表详情
    GetFeedBackDetail(_data) {
        return request.post(Api.GetFeedBackDetial, _data)
    },
    GetFeedBackTaskDetail(_data) {
        return request.post(Api.GetFeedBackTaskDetail, _data)
    },
    // C1 未关闭营销产品名
    MarkProjectName(_data) {
        return request.post(Api.MarkProjectName, _data)
    },
    // C1 处理时长table
    FeedBackC1DurationTable(_data) {
        return request.post(Api.FeedBackC1DurationTable, _data)
    },
    FeedBackC1DurationDetail(_data) {
        return request.post(Api.FeedBackC1DurationDetail, _data)
    },
    // C2 处理时长table
    FeedBackC2DurationTable(_data) {
        return request.post(Api.FeedBackC2DurationTable, _data)
    },
    FeedBackC2DurationDetail(_data) {
        return request.post(Api.FeedBackC2DurationDetail, _data)
    },
    // 回退清空统计
    GoBackCount(_data) {
        return request.post(Api.GoBackCount, _data)
    },
    GoBackCountDetail(_data) {
        return request.post(Api.GoBackCountDetail, _data)
    },
    // 获取退回/激活表格
    GoBackTable(_data) {
        return request.post(Api.GoBackTable, _data)
    },
    GoBackDesc() {
        return request.get(Api.GoBackDesc)
    },
    GoBackDetail(_data) {
        return request.post(Api.GoBackDetail, _data)
    },
    GoBackTableExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.GoBackTableExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                console.log(res)
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    GoBackDetailExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.GoBackDetailExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                console.log(res)
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    // 导出
    ExportStatistics(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.ExportStatistics,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackTaskExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackTaskExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackC1DurationExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackC1DurationExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    FeedBackC2DurationExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackC2DurationExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    GoBackCountDetailExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.GoBackCountDetailExport,
            responseType: 'blob',
            data: _data,
            headers: {
                'Content-Type': 'application/json;charset=UTF-8',
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        })
            .then(res => {
                const objectUrl = URL.createObjectURL(res.data)
                const a = document.createElement('a')
                document.body.appendChild(a)
                a.href = objectUrl
                a.download = decodeURIComponent(res.headers['filename'])
                a.click()
                window.URL.revokeObjectURL(objectUrl)
            })
            .catch(err => {
                console.log(err)
            })
    },
    // 反馈关闭率
    CloseRateFeedBack(_data) {
        return request.post(Api.CloseRateFeedBack, _data)
    },

    // 月度反馈关闭率
    CloseRateMonthly(_data) {
        return request.post(Api.CloseRateMonthly, _data)
    },
    // 月度关闭率详情导出
    exportRateDetailOfMonth(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.exportRateDetailOfMonth,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    FeedBackDetailExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedBackDetailExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    // 月度关闭率表格导出
    exportRateOfMonth(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.exportRateOfMonth,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    FeedbackExport(_data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.FeedbackExport,
            responseType: 'blob',
            data: _data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    // 删除查询条件
    // RemoveSearchCondition(_data) {
    //     return request.post(Api.RemoveSearchCondition + _data)
    // },S
    RemoveSearchCondition(_data) {
        return request.get(Api.RemoveSearchCondition + '?id=' + _data)
    },
    // 获取查询条件
    // querySearchCondition(num) {
    //     return request.get(Api.querySearchCondition + num)
    // },
    querySearchCondition(_data) {
        return request.get(Api.querySearchCondition, {
            params: _data
        })
    },
    // 创建查询条件
    CreateSearchCondition(_data) {
        return request.post(Api.CreateSearchCondition, _data)
    },
    staticChartsMonthly(data) {
        return request.post(Api.staticChartsMonthly, data)
    },
    closeReasonC1(data) {
        return request.post(Api.closeReasonC1, data)
    },
    exportSenve(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.exportSenve,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    senveDetailC1(data) {
        return request.post(Api.senveDetailC1, data)
    },
    solutionC1(data) {
        return request.post(Api.solutionC1, data)
    },
    exportEight(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.exportEight,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    sevenDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.sevenDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    eightDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.eightDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    nineStageC1(data) {
        return request.post(Api.nineStageC1, data)
    },
    nineDetailC1(data) {
        return request.post(Api.nineDetailC1, data)
    },
    exportNine(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.exportNine,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    nineDetialExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.nineDetialExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    tenCharts(data) {
        return request.post(Api.tenCharts, data)
    },

    // C1已关闭阶段时长
    durationStage(_data) {
        return request.post(Api.durationStage, _data)
    },
    durationStageTableExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.durationStageTableExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    // 已关闭阶处理时长详情
    stageDetail(_data) {
        return request.post(Api.stageDetail, _data)
    },
    durationStageDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.durationStageDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    // 部门时长-表格
    durationDep(_data) {
        return request.post(Api.durationDep, _data)
    },
    durationDepExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.durationDepExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    durationDepDetail(_data) {
        return request.post(Api.durationDepDetail, _data)
    },
    durationDepDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.durationDepDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    feedBackSourceTable(_data) {
        return request.post(Api.feedBackSourceTable, _data)
    },
    feedBackSourceTableExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.feedBackSourceTableExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    feedBackSourceTableDetail(_data) {
        return request.post(Api.feedBackSourceTableDetail, _data)
    },
    fedSourceTableDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.fedSourceTableDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },

    c1AndC2Table(_data) {
        return request.post(Api.c1AndC2Table, _data)
    },
    getDetailForC1OrC2(_data) {
        return request.post(Api.getDetailForC1OrC2, _data)
    },
    c1AndC2TableExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.c1AndC2TableExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    c1AndC2TableDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.c1AndC2TableDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    // 无效时长-表格
    invalidTable(_data) {
        return request.post(Api.invalidTable, _data)
    },
    invalidTableDetail(_data) {
        return request.post(Api.invalidTableDetail, _data)
    },
    invalidTableExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.invalidTableExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    },
    invalidTableDetailExport(data) {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + Api.invalidTableDetailExport,
            responseType: 'blob',
            data: data,
            headers: {
                token: JSON.parse(sessionStorage.getItem('USERINFO')).token
            }
        }).then(res => {
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            a.download = decodeURIComponent(res.headers['filename'])
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        }).catch(err => {
            console.log(err)
        })
    }

}
